package info.empathymobile.monitor.receivers;

import info.empathymobile.monitor.EmpathyMonitorController;
import info.empathymobile.monitor.business.beans.MonitorEntry;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BatteryReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if(intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)){
			new EmpathyMonitorController(context).initAsyncEmpathyMonitorScan(MonitorEntry.BATTERY_ENTRY_LOG_CLASS, MonitorEntry.BATTERY_ENTRY_POWER_CONNECTED);
		}
		else if(intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)){
			new EmpathyMonitorController(context).initAsyncEmpathyMonitorScan(MonitorEntry.BATTERY_ENTRY_LOG_CLASS, MonitorEntry.BATTERY_ENTRY_POWER_DISCONNECTED);
		}
	}
}
